﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Cstudy.DAL
{
    public class postTag
    {
        public bool AddPostTag(MODEL.postTag posttag)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@tagname",posttag.TagName),
                new SqlParameter("@tagdescscription",posttag.TagRemarks)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_AddPostTag", parms);
        }

        public bool DeletePostTag(int id)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@tagid",id)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_DeletePostTag", parms);
        }

        public bool UpdatePostTag(MODEL.postTag posttag)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@tagid",posttag.TagID),
                new SqlParameter("@tagname",posttag.TagName),
                new SqlParameter("@tagdescscription",posttag.TagRemarks)
            };
            return COM.SQLHelper.ExecuteNonQuery("sp_UpdatePostTag", parms);
        }

        public DataSet SelectPostTag()
        {
            return COM.SQLHelper.ExecuteQuery("sp_SelectPostTag");
        }

        public DataSet SelectPostTag(int currentPage, int pagesize, out int num, string returnstring)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@count",SqlDbType.Int)
            };
            parms[0].Direction = ParameterDirection.Output;

            return COM.SQLTools.ExecuteQuery("sp_SelectPostTagPager", parms, currentPage, pagesize, out num, returnstring);
        }
    }
}
